import { Component, OnInit } from '@angular/core';
import { ColumnType, SPage } from '@shared/components/table-page/table-page.component';
import { ApiService } from '@core/services/api';
import { NzModalService } from 'ng-zorro-antd';
import { ServiceLogComponent } from '../service-log/service-log.component';

@Component({
  selector: 'app-sys-log',
  templateUrl: './sys-log.component.html',
  styles: []
})
export class SysLogComponent implements OnInit {
  config: SPage = {
    columns: [
      {
        title: '服务名称',
        index: 'serviceName',
      },
      {
        title: '运行状态',
        index: 'serviceStatus',
        type: ColumnType.tag,
        tag: {
          1: {text: '正常', color: 'green'},
          2: {text: '续约', color: 'orange'},
          0: {text: '异常', color: 'red'},
        },
      },
      {
        title: '记录时间',
        index: 'updateTime'
      },
      {
        title: '备注',
        index: 'serviceRemark'
      }
    ],
    editBtn: [
      {title: '查看'}
    ],
    defaultParam: {
      order: 'update desc'
    },
    reqUrl: this.api.Log.sysLog.url
  }
  constructor(
    private api: ApiService,
    private modal: NzModalService
  ) { }

  ngOnInit() {
  }
  preview(e): void {
    this.modal.create({
      nzTitle: '服务运行日志',
      nzContent: ServiceLogComponent,
      nzWidth: '70%',
      nzComponentParams: {
        param: e.data
      },
      nzFooter: null
    })
  }
}
